﻿using System.Data;
using LibDBConnect;

namespace LibDataLayer
{
    public static class DalForumMini
    {
        private static readonly SqlHelper Cls = new SqlHelper();
        #region[Get-Data]
        public static DataTable GetForumMini(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("KEYWORDS", keywords);
            return Cls.GetData("sp_ForumsMini_Get");
        }
        public static DataTable GetForumMiniEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fmid", id);
            return Cls.GetData("sp_ForumsMini_Get_Edit");
        }
        public static DataTable GetForumMiniFillterStatus(int IsActive)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("IsActive", IsActive);
            return Cls.GetData("sp_ForumsMini_Get_FillterStatus");
        }
        public static DataTable GetForumMiniFillterCategories(int Fmid)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fid", Fmid);
            return Cls.GetData("sp_ForumsMini_Get_FillterCategories");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(DTOForumMini obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fname", obj.Fname);
            Cls.AddParameter("Fdesc", obj.Fdesc);
            Cls.AddParameter("RedirectUrl", obj.RedirectUrl);
            Cls.AddParameter("Moderators", obj.Moderators);
            Cls.AddParameter("SortBy", obj.SortBy);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            Cls.AddParameter("Fid", obj.Fid);
            Cls.AddParameter("Short", obj.Short);
            return Cls.ExecuteNonQuery("sp_ForumsMini_Insert");
        }
        public static bool Update(DTOForumMini obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fmid", obj.Fmid);
            Cls.AddParameter("Fname", obj.Fname);
            Cls.AddParameter("Fdesc", obj.Fdesc);
            Cls.AddParameter("RedirectUrl", obj.RedirectUrl);
            Cls.AddParameter("Moderators", obj.Moderators);
            Cls.AddParameter("SortBy", obj.SortBy);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            Cls.AddParameter("Fid", obj.Fid);
            Cls.AddParameter("Short", obj.Short);
            return Cls.ExecuteNonQuery("sp_ForumsMini_Update");
        }
        public static bool Delete(DTOForumMini obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fmid", obj.Fmid);
            obj.Msg = Cls.ExecuteNonQueryOutput("sp_ForumsMini_Delete", "@Msg");
            return true;
        }
        public static bool UpdateNum(DTOForumMini obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fmid", obj.Fmid);
            Cls.AddParameter("DispPosition", obj.DispPosition);
            return Cls.ExecuteNonQuery("sp_ForumsMini_Update_Num");
        }
        public static bool UpdateCheck(DTOForumMini obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fmid", obj.Fmid);
            Cls.AddParameter("IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_ForumsMini_Update_Check");
        }
        #endregion

        #region[Get-Data-HomePage]
        public static DataTable GetForumMiniHomePage(int Fid)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Fid", Fid);
            return Cls.GetData("sp_ForumsMini_Get_HomePage");
        }
        #endregion
    }
    public class DTOForumMini
    {
        public int ? Fmid { get; set; }
        public string Fname { get; set; }
        public string Fdesc { get; set; }
        public string RedirectUrl { get; set; }
        public string Moderators { get; set; }
        public int ? SortBy { get; set; }
        public int ? DispPosition { get; set; }
        public int ? Fid { get; set; }
        public bool IsActive { get; set; }
        public int Msg { get; set; }
        public string Short { get; set; }
    }
}